<#include "/admin/system/metadata/table/head.html">
<div class="layui-tab">
   <div class="layui-tab-content" style="padding:0px;">
       <div class="layui-tab-item layui-show">
           <div class="box default-box" style="height: 100%;">
               <div class="box-header">
                   <h3 class="box-title">表数据列表
                       <#if dataList??>（${dataList.totalElements}）</#if></h3>
               </div>
               <div class="box-body ukefu-im-theme">
                   <div class="row" style="padding:5px;overflow: auto;">
                       <div class="col-lg-12">
                           <table class="layui-table" lay-skin="line">
                               <thead>
                                   <#if table.tableproperty?? && dataList?? && dataList.content?? && dataList?? && dataList.content?size gt 0>
                                       <tr>
                                           <th>
                                               <input type="checkbox" id="all" onclick="$('.ids').prop('checked' , $(this).prop('checked'));" /></th>
                                           <#list table.tableproperty as prop>
                                               <#if prop.viewtype?? && prop.viewtype?index_of( 'list') gte 0>
                                                   <th nowrap="nowrap">${prop.name!''}</th></#if>
                                           </#list>
                                           <th style="white-space:nowrap;" nowrap="nowrap">操作</th></tr>
                                   </#if>
                               </thead>
                               <tbody>
                                   <#if dataList?? && dataList.content?? && dataList.content?size gt 0>
                                       <#list dataList.content as data>
                                           <tr>
                                               <td style="width:1%;">
                                                   <input type="checkbox" class="ids" name="ids" value="${prop.id!''}" /></td>
                                               <#if table.tableproperty??>
                                                   <#list table.tableproperty as prop>
                                                       <#if prop.viewtype?? && prop.viewtype?index_of( 'list') gte 0>
                                                           <th><#if data.values[(prop.fieldname)?lower_case]?? && data.values[(prop.fieldname)?lower_case]?is_enumerable == false>${data.values[(prop.fieldname)?lower_case]}</#if></th></#if>
                                                   </#list>
                                               </#if>
                                               <td style="white-space:nowrap;width:1%;" nowrap="nowrap">
                                                   <a href="/admin/metadata/estable/data/edit.html?dataid=${data.values.id!''}&tableid=${table.id!''}&tabletype=${tabletype!''}" data-width="850" data-height="520" data-toggle="ajax" title="编辑${table.name!''}">
                                                       <i class="layui-icon">&#xe642;</i>编辑</a>
                                                   <#if tabletype?? && tabletype != '3'>
	                                                   <a href="/admin/metadata/estable/data/delete.html?dataid=${data.values.id!''}&tableid=${table.id!''}&tabletype=${tabletype!''}" data-toggle="tip" title="请确认是否删除该条数据？">
	                                                       <i class="layui-icon" style="color:red;">&#x1006;</i>删除</a>
                                                   </#if>
                                               </td>
                                           </tr>
                                       </#list>
                                       <#else>
                                           <div class="ukefu-empty">
                                               <i class="layui-icon"></i>
                                               <div style="">还没有数据记录</div></div>
                                   </#if>
                               </tbody>
                           </table>
                       </div>
                   </div>
                   <div class="row" style="padding:5px;">
						<div class="col-lg-12" id="page" style="text-align:center;"></div>
					</div>
               </div>
           </div>
       </div>
   </div>
</div>
<script>
	$(document).ready(function(){
		$('#batdel').click(function(){
			var ids = "";
			$('.ids').each(function(){
				if($(this).prop("checked")){
					if(ids!=""){
						ids += "&" ;
					}
					ids += "ids=" + $(this).val();
				}
			});
			$('#batdel').attr('href' , '/admin/metadata/properties/batdelete.html?tbid=${tbid!''}&'+ids)	;
			
		});
		$('#batedit').click(function(){
			var ids = "";
			$('.ids').each(function(){
				if($(this).prop("checked")){
					if(ids!=""){
						ids += "&" ;
					}
					ids += "ids=" + $(this).val();
				}
			});
			$('#batedit').attr('href' , '/admin/metadata/properties/update/mul.html?dbtableid=${table.dbtableid!''}&tbid=${tbid!''}&'+ids)	;
			
		});
	});	
	layui.use('layer', function(){
		  var layer = layui.layer;
		  <#if msg?? && msg == 'bat_delete_success'>
		  layer.alert('批量删除元数据成功！', {icon: 6});
		  <#elseif msg?? && msg == 'bat_delete_faild'>
		  layer.alert('请勾选需要删除的记录！', {icon: 5});
		  </#if>
		}); 
	layui.use(['laypage', 'layer'], function(){
		  var laypage = layui.laypage
		  ,layer = layui.layer;
		  <#if msg??>
		  top.layer.msg('${msg}');
		  </#if>
		  laypage.render({
				elem: 'page'
				,pages: <#if dataList??>${dataList.totalPages}<#else>0</#if> //总页数
				,curr:<#if dataList??>${dataList.number+1}<#else>0</#if>
				,groups: 5 //连续显示分页数
				,jump:function(data , first){
					if(!first){
						location.href = "/admin/metadata/table/data.html?p="+data.curr +"&id=${table.id!''}";
					}
				}
		   });
		});
</script>
